

# on wake up normal variables
WIFE_HOME			string		Note: Do not use anymore. Used to be the full path to wife home directory / folder. Now it's one step up from the wife system folder.
HOME_PATH			string		The full path to wife home directory / folder (the base directory of the installed application).
SYSTEM_PATH			string		The full path to wife system directory / folder.
WIFE_RELEASE_VERSION	integer		release version
WIFE_BETA_VERSION		integer		beta version (99=release)
WIFE_SP_VERSION			integer 	service pack version
SESSION					id			a session number used to tell wife when the script can exit
USER_ID					id			internal wife id of the user who fired the script
USER_SHORT				string		user's short name / login name eg. Johnny
LOCALE_LIST				string		The system/user specific list separator character, usable for example when creating CSV files. For example "," or ";". Configured in the Client Setup window.
LOCALE_DECIMAL			string		The system/user specific decimal character. Typically "." or ",". Configured in the Client Setup window.
LOCALE_THOUSAND			string		The system/user specific thousand separator character. Typically "" (empty), "," or ".". Configured in the Client Setup window.
LOCALE_SHORTDATE		string		The system/user specific date format. Can be "" if not configured. Otherwise typically "%Y-%m-%d" or similar. Configured in the Client Setup window.
LOCALE_TIME		string		The system/user specific time format. Can be "" if not configured. Otherwise typically "%H:%M:%S" or similar. Configured in the Client Setup window.


# specific variables of interest
INVOICES_SELECTED			list		a list of the selected invoices, each element in the list = see below
INVOICES_SELECTED_CUSTOMS	list		a list in sync with INVOICES_SELECTED, each is a list with the custom fields (i1=label, i2=value)
INVOICES_SELECTED_CLIENT	list		a list in sync with INVOICES_SELECTED, each is a list with the full contact data
INVOICES_SELECTED_SOURCES		list	a list in sync with INVOICES_SELECTED, each is a list with the full project or mediaorder data
INVOICES_SELECTED_SOURCES_TYPE	list	a list in sync with INVOICES_SELECTED, each is a string identifying the source type: "prj" or "mo"
INVOICE_MODULE				string		"manager" = sended invoices / "creator" = new invoices 


# AN INVOICE
index	var			type		desciption

## this is the final column names that this script creates
## invoice main data
# 00	i_id				id			a click with date
# 01	i_name				string		name of the job
# 02	i_number			int			invoice number
# 03	i_company_client_id	id			the contact client's wife id
# 04	i_company_number	string		the client's number
# 05	i_company_textualid	string		the client's textual id
# 06	i_company_contact	string		the contact name
# 07	i_company_company	string		the company name
# 08	i_company_adress	string		the company address
# 09	i_company_id		id			the company wife id
# 10	i_our_ref			string		our reference
# 11	i_template			string		the print template to use
# 12	i_credit_note		string		if not empty, then it holds the invoice_number to be credited, and ,i_total_no_vat, i_total_vat holds the totals
# 13	i_source_type		int			0=project 1=mediaorder, or -1 custom
# 14	i_source_id			id			id of prj, or mediaorder
# 15	i_source_number		string		number of prj, or mediaorder
# 16	i_fixed_price		bool		bool if it is a fixed price
# 17	i_total_no_vat		int			total
# 18	i_total_vat			int			total + vat
# 19	i_vat				int			how much VAT
# 20	i_vat_name			string		name of VAT
# 21	i_objects			list		SEE: see i_objects, (IN FILE ON SERVER)
# 22	i_paid				bool		if invoice has been paid
# 23	i_due				int			450, eg, when the invoice is due in "intday" format
# 24	i_note				string		a main note for the invoice
# 25	i_owner				string		full name of user
# 26	i_po				string		po of project or mediaorder
# 27	i_currency			list		0=name (string), 1=conversion rate (double)
# 28	i_created_intday	int			same as id but in intday format
# 29	i_transfered		bool		if the invoice has been transfered to the finacial system
# 30	i_vat_mode			bool		if vat has to be applied before discount
# 31	i_paid_note			string		4.3 note for paid info
# 32	i_name_only			string		4.4 just the name, no container
# 33	i_part_invoice		bool		4.5 defines if the invoice was done as a part_invoice
# 34  	i_fiscal_year		int 		4.6 defines the fiscal year where the invoice was done
# 35	i_datev_number		int 		4.6 special generated datev number (only when available)
# 36  	i_credit_exits		bool 		4.7 indicates if already exists a Credit Note related with this Invoice
# 37	i_sap_number		int			4.8 SAP Number (copied from the Project/Media Order)
# 38	i_paid_date			int			4.8 intday with the day that the invoice was paid (empty if no date defined)
# 39	i_paid_setby		id			4.8 user id who set the invoice as paid
# 40?	i_custom0			list		4.6 user defined custom fields, see INVOICE_CUSTOMS, value only
.......
....
#
## each element row
# 00	io_came_from_type	string		booking, smartbooking, material, service, expense, reentry, operator, workorder, mediaorder
# 01	io_came_from_id		id			id of eg. a booking == always a added_id if you think about it
# 02	io_came_from_header	string		if: smartbooking = name + start date and stop date, workorder = workorder name, mediaorder = mediaorder name
# 03	io_came_from_note	string		eg. timereport booking note etc..
# 04	io_came_from_po		string		po of booking, or workorder etc....
# 05	io_came_from_numref	string		ML / 25 = user + unique ref added number
# 06	io_var				string		SEE: io object group
# 07	io_id				id			id of the object
# 08	io_name				string		Inferno, note activity is appended to the name if any
# 09	io_icon				string		"room6" the icon name
# 10	io_quant			double/int	how many
# 11	io_quant_type		string		0=days 1=hours 2=units 3=fixed price, OR A String containing the timeunit quant name
# 12	io_sell				int			per unit rate in money
# 13	io_disc				double/int	discount
# 14	io_note				string		note on element level
# 15	io_ref				string		object ref num
# 16	io_added_id			id			4.1 0=id,when it was "day of booking / performed / done / reported" !! ?1=intday list 2=inout
# 17	io_add_vat			bool		normaly 1, unless you live in denmark???
# 18	io_ac				id			?id of activity if used
# 19	io_buy				int			4.3 beta31 buy rate in money
# 20	io_fin_id			id			financial id for this invoice line. this originally comes from a source of financial information, for example a cb_co or a wo_object.
# 21  	io_po_buy			money		4.8 if not empty, then contains the po line buy rate. That's the PO Line total
# 22	io_multiplier		int			4.9 "how many objects". for example 3 x 2 days of Cameraman. Then io_quant will be 6 and io_multiplier will be 3.
# 23	io_quant_bef_mult	int			4.9 quantity before multiplier. for example 3 x 2 days of Cameraman. Then io_quant will be 6 and io_quant_bef_mult will be 2.

# io object group can be
user
room
machine
other
timeunit
checkpoint
group
resource
material
service
expense
mediaorder
reentry
operator
external
fixed_price
prepayment
prepayment_perc (the only difference with prepayment is visually, in the way accepts the values)

## INVOICE_CUSTOMS
0	type			int			0=entry(see finder), 1=text, 2=selector, 3=date, 4=checkbox(see cbs), 5=files
1	label			string		the label name			
2	value			???			value of the entry,text or cb. can contain extra data, and is then in the format: (CUSAUX value import_source aux_data).
3	finder			int			0=no finder  , 1=contacts NAMES,  2=contacts COMPANIES
4	value_list		int			list of elems to present if checkbox
5	permission		int			0/1/2. who shall get the info
6	import			string		3.2 what field to import
7	mandatory		bool		if setting a value in the custom field is mandatory. NOTE: can be empty string in old data
8	ecusdate		bool		media entry customs only: "Embed Date". NOTE: can be empty string in old data
9	unique			bool		media entry customs only: "Must Be Unique". NOTE: can be empty string in old data
10	multiple_files	bool		file custom fields only: if it can hold mustible files or not. NOTE: can be empty string in old data
11	import_source	list		entry+import customs only: information about the source of the imported data. format: ("contact" contact_id)
12	aux_data		list		entry+import customs only: list of extra contact data that is invisibly stored in the custom field. list of (key type value).
								type: 0 means string, 1 means intday, 2 means boolean.
